package com.cskaoyan._08game._02pvz;

/**
 * @description:
 * @author: 景天
 * @date: 2023/2/6 9:58
 **/
// 定义僵尸类模板
public class Zombie {
    // 定义成员变量
    String name;
    int damage;
    int hp;
    int speed;


    // 持有对方的引用 ,方便交互
    Plant plant;

    public Zombie(String name, int damage, int hp, int speed) {
        this.name = name;
        this.damage = damage;
        this.hp = hp;
        this.speed = speed;
    }

// 定义成员方法

    public void attack() {
        System.out.println(name + "正在攻击" + plant.name);
    }
    public void beAttacked() {
        System.out.println(name + "正在被" + plant.name + "攻击" +
                "血量剩余:" + (hp - plant.damage));
        // 把扣过的血量重新赋值
        this.hp = this.hp - plant.damage;
    }

    public void move() {
        System.out.println(name + "正在以" + speed + "米/s的速度向你移动");
    }

    public void eat() {
        System.out.println("你的脑子被吃了,嘎嘎香");

    }
}
